<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.ArrayList"  %>


<%
     String parentPath = request.getParameter("parentPath");
     String problemName = request.getParameter("problemName");
     String products[] = {"ESB","GReg","IS","BAM","GS","BPS","MS","DSS","WSAS","WSF"};
/*
     String ESB[] = {"2.1.3","2.1.2","2.1.1","2.1.0","2.0.2","2.0.1","2.0"};
     String GReg[] = {"3.0.3","3.0.2","3.0.1","3.0.0","2.0"};
     String IS[] = {"2.0.3","2.0.2","2.0.1","2.0.0"};
     String BAM[] ={"1.0.1"};
     String GS[] = {"1.0.1"};
     String BPS[] = {"1.1.1","1.1.0","1.0.1","1.0"};
     String MS[] = {"2.0.2","2.0.1","2.0.0","1.5.2"};
     String DSS[] = {"2.2.1","2.2.0","2.0.0","1.0.1"};
     String WSAS[] = {"3.1.3","3.1.2","3.1.1","3.0.1","3.0"};
*/
     String cP[] = {"2.0.3","2.0.2","2.0.1","2.0.0"};
     String jdkP[] = {"1.6","1.5"};
%>
<html>
    <head>
<script type="text/javascript" src="/carbon/registry_common/js/registry_common.js"></script>

<script type="text/javascript">
 
    
    var qn = new Array();
    var ans = new Array();
    var sol = new Array();
    var i = 0;
    var j = 0;

/*
    ShowHideCommon = function (divId){
	var theDiv = document.getElementById(divId);
	if(theDiv.style.display=="none"){
		theDiv.style.display="";
	}else{
		theDiv.style.display="none";
	}
    }
*/

    AddQnAToArray = function () {



        var qnaDivId = 'qID';

        qn[i] = document.getElementById("question").value;
        document.getElementById("question").value="";
        ans[i] = document.getElementById("answer").value;
        document.getElementById("answer").value="";

        i++;

        document.getElementById("qnArray").value=qn;
        document.getElementById("ansArray").value=ans;

        showHideCommon(qnaDivId);

        var tID = document.getElementById("qnatID");
        var qnaTdID = document.getElementById("qnaTdID");
        var newTr = document.createElement("tr");
        var divIdName = 'qnatr'+i;

        newTr.setAttribute('id',divIdName);

        newTr.innerHTML = '<table border="1"><tr colspan="2"><td>Question '+i+'</td><td>'+qn[i-1]+'</td></tr><tr colspan="2"><td>Answer '+i+'</td><td>'+ans[i-1]+'</td></tr></table>';

        tID.appendChild(newTr);
        qnaTdID.appendChild(tID);


   
    }

    AddSolToArray = function () {

        var solDivId = 'sID';

        sol[j] = document.getElementById("solution").value;
        document.getElementById("solution").value="";

        j++;

        document.getElementById("solArray").value=sol;

        showHideCommon(solDivId);

        var tID = document.getElementById("soltID");
        var solTdID = document.getElementById("solTdID");
        var newTr = document.createElement("tr");
        var divIdName = 'soltr'+j;

        newTr.setAttribute('id',divIdName);

        newTr.innerHTML = '<table border="1"><tr colspan="2"><td>Solution '+j+'</td><td>'+sol[j-1]+'</td></tr></table>';

        tID.appendChild(newTr);
        solTdID.appendChild(tID);



    }



</script>
    </head>

<br/>



<form id="skbAddForm" action="../registry/custom/skb/skb_add_handler_ajaxprocessor.jsp" method="post">
<input type="hidden" name="parentPath" id="parentPath" value="<%=parentPath%>"/>
<table style="width:100%" class="styledLeft">
	<thead>
		<tr><strong>Add a new Problem</strong>
		</tr>
	</thead>
	<tbody>
    <tr>
        <td class="leftCol-med">Problem Name<span class="required">*</span></td>
        <td><input type="text" id ="problemName" name="problemName"/></td>
    </tr>
     <tr>
        <td>Description</td>
        <td><input type="text" id ="description" name="description"/></td>
    </tr>
    <tr>
        <td>Issue Link<span class="required">*</span></td>
        <td><input type="text" name="link"/></td>
    </tr>
    <tr>
                <td>Question & Answer</td>
                
                <td id="qnaTdID">
                    
                <div class="icon-link-ouside registryWriteOperation">
                <a class="icon-link registryWriteOperation" style="background-image:url(../admin/images/add.gif);" onclick="javascript:showHideCommon('qID');if($('qID').style.display!='none')document.forms.skbAddForm.question.focus()">Add Question & Answer</a>
                </div>

                <div id="qID" style="display:none;">
                <form onsubmit="return AddQnAToArray();" name ="addQnA">
                    <input type="hidden" name="qnArray" id="qnArray" value=""/>
                    <input type="hidden" name="ansArray" id="ansArray" value=""/>
                    <table cellpadding="1" cellspacing="1" border="1" class="styledLeft">
                        <thead>
                            <tr>
                                <th colspan="2">Add New Question & Answer</th>

                            </tr>
                        </thead>
                        <tbody>

                            <tr>
                                <td valign="top">Question<span class="required">*</span></td>
                                <td><textarea  name="question" id="question" class="normal-textarea"></textarea>

                                </td>
                            </tr>
                            <tr>
                                <td valign="top">Answer<span class="required">*</span></td>
                                <td><textarea  name="answer" id="answer" class="normal-textarea"></textarea>

                                </td>
                            </tr>
                            <tr>

                                <td colspan="2" class="buttonRow"><input type="button" class="button" value="Add" onclick="AddQnAToArray();"><input style="margin-left:5px;" type="button" class="button" value="Cancel" onclick="javascript:showHideCommon('qID');">
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </form>
                </div>
                
                <table id="qnatID" name="qnatID">

                </table>
                </td>

    </tr>    
    <tr>
        <td>Solution</td>

                <td id="solTdId">
                <div class="icon-link-ouside registryWriteOperation">
                <a class="icon-link registryWriteOperation" style="background-image:url(../admin/images/add.gif);" onclick="javascript:showHideCommon('sID');if($('sID').style.display!='none')document.forms.skbAddForm.solution.focus()">Add Solution</a>
                </div>
                <div id="sID" style="display:none;">
                    <input type="hidden" name="solArray" id="solArray" value=""/>
                    <table cellpadding="0" cellspacing="0" border="0" class="styledLeft">
                        <thead>
                            <tr>
                                <th colspan="2">Add New Solution</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td valign="top">Description<span class="required">*</span></td>
                                <td><textarea  name="solution" id="solution" class="normal-textarea"></textarea>
                                </td>
                            </tr>
                            <tr>

                                    <td colspan="2" class="buttonRow"><input type="button" class="button" value="Add" onclick="AddSolToArray();"><input style="margin-left:5px;" type="button" class="button" value="Cancel" onclick="javascript:showHideCommon('sID');">
                                    </td>
                            </tr>

                        </tbody>
                    </table>
                </div>
                <table id="soltID" name="soltID">

                </table>
                </td>
    </tr>
    <tr>
        <td>Related Product</td>
        
                <td>
                <div class="icon-link-ouside registryWriteOperation">
                <a class="icon-link registryWriteOperation" style="background-image:url(../admin/images/add.gif);" onclick="javascript:showHideCommon('pID');">Add Product</a>
                </div>
                <div id="pID" style="display:none;">
                <table cellpadding="0" cellspacing="0" border="0" class="styledLeft">
                
                    <tbody>
                        <tr>
                        <td>Product</td>
                        <td>
                        <select name="product" id="product" >
                        <%
                        for(int i=0; i< products.length; i++){
                            String name1 = products[i];
                            %>
                            <option value="<%= name1%>"><%= name1%></option>
                            <%
                        }
                        %>
                        </select>
                        </td>
                        </tr>
                       <tr>
                        <td>Product Release</td>
                        <td><input type="text" name="productRelease" id="productRelease"/></td>
                        </tr>

                    </tbody>
                </table>
                </div>
                </td>

                
    </tr>
    <tr>
        <td>Environment</td>

                <td>
                <div class="icon-link-ouside registryWriteOperation">
                <a class="icon-link registryWriteOperation" style="background-image:url(../admin/images/add.gif);" onclick="javascript:showHideCommon('eID');">Add Environment</a>
                </div>
                <div id="eID" style="display:none;">
                <table cellpadding="0" cellspacing="0" border="0" class="styledLeft">
                    <tbody>
                        <tr>
                        <td>Carbon Platform</td>
                        <td>
                        <select name="carbonPlatform" id="carbonPlatform" >
                        <%
                        for(int i=0; i< cP.length; i++) {
                            String name1 = cP[i];
                            %>
                            <option value="<%= name1%>"><%= name1%></option>
                            <%
                        }
                        %>
                        </select>
                        </td>
                        </tr>
                        <tr>
                        <td>JDK Platform</td>
                        <td>
                        <select name="jdkPlatform" id="jdkPlatform" >
                        <%
                        for(int i=0; i< jdkP.length; i++) {
                            String name1 = jdkP[i];
                            %>
                            <option value="<%= name1%>"><%= name1%></option>
                            <%
                        }
                        %>
                        </select>
                        </td>
                        </tr>

                    </tbody>
                </table>
                </div>
                </td>
    </tr>
    <tr>
        <td>Tags</td>
        <td>
        <div class="icon-link-ouside registryWriteOperation">
        <a class="icon-link registryWriteOperation" style="background-image:url(../admin/images/add.gif);" onclick="javascript:showHideCommon('kwID');if($('kwID').style.display!='none')document.forms.diaAddForm.question.focus()">Add Tag</a>
        </div>
        <div id="kwID" style="display:none;">
                <table cellpadding="0" cellspacing="0" border="0" class="styledLeft">
                    <tbody>
                        <tr>
                          <td><input type="text" name="keyWord"/></td>  
                        </tr>
                    </tbody>
                        <div style="font-style:italic;margin-top:5px;">
                        <img src="../info/images/help-small.jpg" style="margin-right:5px;">
                        Use commas ("one, two") to add multiple tags.
                        </div>
                </table>
                </div>
        </td>
        
    </tr>

    <tr>
        <td colspan="2" class="buttonRow"><input class="button" type="submit" value="Save"/></td>
    </tr>
    </tbody>
</table>
</form>

<br/>



</html>